{% extends "base_sub.html" %}
{% import "/sideview/macros.html" as sideview %}
{% set action='已收回' if kind == "recv" else '已发送' %}

{% block title %}我的便笺框{% endblock title %}

{% block content %}
    <div id="memo_list" class="new_win">
        <h1 id="win_title">
            <i class="fa fa-regular fa-envelope" aria-hidden="true"></i> 我的便笺框
            <div class="win_total">
                已满 {{ action }}备注 
                {{ total_records|number_format }}高大
                <br>
            </div>
        </h1>
        <div class="new_win_con2">
            <ul class="win_ul">
                <li class="{% if kind == "recv" %}selected{% endif %}"><a href="{{ url_for('memo_list') }}?kind=recv">收到一张纸条</a></li>
                <li class="{% if kind == "send" %}selected{% endif %}"><a href="{{ url_for('memo_list') }}?kind=send">已发送便笺</a></li>
                <li><a href="{{ url_for('memo_form') }}">写一个便条</a></li>
            </ul>
            <div class="memo_list">
                <ul>
                {% for memo in memos %}
                    {% set is_read=(False if is_none_datetime(memo.me_read_datetime) else True) %}
                    {% set target_member=memo.target_member %}
                    <li class="{% if is_read %}read{% endif %}">
                        <div class="memo_li profile_big_img">
                            <img src="{{ get_member_image(target_member.mb_id) }}" alt="profile_image">
                            {% if not is_read %}
                                <span class="no_read">未阅读的便条</span>
                            {% endif %}
                        </div>
                        <div class="memo_li memo_name">
                            {{ sideview.get(request, target_member.mb_id, target_member.mb_nick|default("[无会员信息]"))|safe }}
                            <span class="memo_datetime">
                                <i class="fa fa-regular fa-clock" aria-hidden="true"></i>
                                {{ memo.me_send_datetime }}
                            </span>
                            <div class="memo_preview">
                                <a href="{{ url_for('memo_view', me_id=memo.me_id) }}?{{ request.query_params }}">
                                    {{ memo.me_memo|truncate(50, True, '...') }}
                                </a>
                            </div>
                        </div>	
                        <a href="{{ url_for('memo_delete', me_id=memo.me_id) }}?page={{ page }}" onclick="del(this.href); return false;" class="memo_del"><i class="fa fa-regular fa-trash-can" aria-hidden="true"></i> <span class="blind">删除</span></a>
                    </li>
                {% else %}
                    <li class="empty_table">{{ action }} 无备注.</li>
                {% endfor %}
                </ul>
            </div>
    
            {{ paging|safe }}

            <p class="win_desc">
                <i class="fa fa-info-circle" aria-hidden="true"></i>
                存储天数的记录 <strong>{{ request.state.config.cf_memo_del|number_format }}</strong>是工作..
            </p>
    
            <div class="win_btn">
                <button type="button" onclick="window.close();" class="btn_close">窗口关闭</button>
            </div>
        </div>
    </div>
{% endblock content %}